<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./lib/vue_2.5.22.js"></script>
    <script src="./lib/vue-router_3.0.2.js"></script>
</head>

<body>
    <div id="app">
        <!-- 创建路由标签 使用router-link组件来导航 -->
        <router-link to="/login/user1">login</router-link>
        <router-link to="/login/user2">login</router-link>
        <router-link to="/login/user3">login</router-link>
        <router-link to="/register">register</router-link>
        <!-- 创建占位符 -->
        <router-view></router-view>

    </div>
    <script>
        //创建路由组件
        var Login = {
            props: ['id', 'name', 'age'],
            template: `
            <div>
            <h4>登录-----{{id}}----{{name}}----{{age}}</h4>
            </div>
            `
        }
        var Register = {
                template: `
            <div>
            <h4>注册</h4>
            </div>
            `
            }
            //创建路由规则
        var router = new VueRouter({
            // routes: [{
            //     path: '/login/:id',
            //     component: Login,
            //     props: true
            // }, {
            route: [{
                path: '/login/:id',
                component: Login,
                props: {
                    name: 'zhangshan',
                    age: 12
                }
            }, {
                path: '/register',
                component: Register
            }]
        })
        var vm = new Vue({
            el: '#app',
            router
            // 将路由对象进行挂载
        })
    </script>
</body>

</html>